#pragma once

#include "ClientChannel.h"

namespace nio {

	class ServerChannel : public Selectable
	{
	private:
		Socket* socket = nullptr;
		ChannelDelegate* delegate = nullptr;
	public:
		EventLoop* eventLoop = nullptr;
	public:
		ServerChannel(ChannelDelegate* delegate);
		virtual ~ServerChannel();

		void startServer(std::string ip, int port);
		void stopServer();

	public:
		virtual SOCKET getFD();
		virtual void onEvents(int events);

	private:
		void onAcceptable();
		void onError(SocketError* error);
	};

}